﻿using System.Web;
using FFIV.Lib.BusinessRules;
using FFIV.Lib.IView.Articles;
using FFIV.Lib.Utilities;

namespace FFIV.Lib.Controlers.Articles
{
	public class ArticleSearchController
	{
		private IArticlesList m_List;
		private IArticlesMiniList m_MiniList;

		public ArticleSearchController(IArticlesList view, IArticlesMiniList miniList)
		{
			m_List = view;
			m_MiniList = miniList;
		}

		public void LoadPage()
		{
			string title = ParamUtility.GetQueryStringValue("title", "");
			m_List.Articles = ArticlesRules.GetArtivleByTitle(HttpUtility.UrlDecode(title));
			m_List.NextPageUrl = UrlUtility.GetSearchUrl(title, m_List.PageIndex + 1);
			m_List.PreviousPageUrl = UrlUtility.GetSearchUrl(title, m_List.PageIndex - 1);

			m_MiniList.Articles = ArticlesRules.GetFavorArticles();
		}
	}
}